package com.party.core.model.member;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * 第三方用户类型
 * Created by yifeng
 *
 * @date 2018/2/24 0024
 * @time 上午 11:26
 */
public enum ThirdPartyUserType {
    APP_WECHAT(0, "app微信授权"),

    QQ(1, "qq授权"),

    WEIBO(2, "微博授权"),

    WECHAT_OFFICIAL(3, "微信公众号授权"),

    WECHAT_MINI_PROGRAM(4, "小程序授权");

    private Integer code;

    private String value;

    ThirdPartyUserType(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static String getValue(Integer code) {
        for (ThirdPartyUserType memberType : ThirdPartyUserType.values()) {
            if (memberType.getCode().equals(code)) {
                return memberType.getValue();
            }
        }
        return null;
    }

    public static Map<Integer, String> convertMap() {
        Map<Integer, String> map = Maps.newHashMap();
        for (ThirdPartyUserType memberType : ThirdPartyUserType.values()) {
            map.put(memberType.getCode(), memberType.getValue());
        }
        return map;
    }
}
